<template>
  <div class="son">
    哥哥
    <div v-show="toy"> 弟弟给的玩具 {{toy}}</div>
  </div>
</template>

<script setup lang="ts">
import emitter from "@/utils/emitter";
import {onUnmounted, ref} from "vue";

  const toy = ref<string>('');
  emitter.on('send-toy', (value : string) => {
    toy.value = value;
  })

  // 解绑
  onUnmounted(() => {
    emitter.off('send-toy');
  })
</script>

<script lang="ts">
/**
 * @Author Rin_pu
 * @Date 2025/2/21 14:43
 * @Description son1
 * @todo
 */
export default {
  name: "son1.vue"
}
</script>

<style scoped>
.son {
  background-color: green;
  margin: auto;
  width: 80%;
  height: 40%;
}
</style>